package butines.core;

public class Timer {

	private static final int   TIMER_RESOLUTION = 1000000000;
    private static final float INVERSE_TIMER_RESOLUTION = 1f / TIMER_RESOLUTION;
    
    private long startTime;
    private long lastTime;     
    private long frameTime;
    private float deltaTime;  
    
    public Timer() {
    }

    public static long getTime() {
        return System.nanoTime();
    }

    public long getResolution() {
        return TIMER_RESOLUTION;
    }

    public float getDeltaTime() {
        return deltaTime;
    }

    public float getStartTime() {
		return startTime;
	}

	public float getFrameTime() {
		return frameTime;
	}

	public void tick() {
    	frameTime = getTime();
        deltaTime = (frameTime - lastTime) * INVERSE_TIMER_RESOLUTION;
        lastTime = frameTime;
    }
	
    public void init() {
    	frameTime = getTime();
    	startTime = frameTime;
        lastTime  = frameTime;
    }
    
}